from django.contrib import admin
from .models import UserStats, DailyStats


@admin.register(UserStats)
class UserStatsAdmin(admin.ModelAdmin):
    """用户统计数据管理"""
    list_display = ['id', 'user', 'total_artworks', 'painting_count', 'music_count', 'writing_count', 
                    'total_views', 'total_likes', 'total_comments', 'updated_at']
    list_filter = ['updated_at']
    search_fields = ['user__username']
    readonly_fields = ['updated_at']
    list_per_page = 20
    
    fieldsets = [
        ('用户信息', {
            'fields': ['user']
        }),
        ('作品统计', {
            'fields': ['total_artworks', 'painting_count', 'music_count', 'writing_count']
        }),
        ('互动统计', {
            'fields': ['total_views', 'total_likes', 'total_comments']
        }),
        ('时间信息', {
            'fields': ['updated_at']
        }),
    ]


@admin.register(DailyStats)
class DailyStatsAdmin(admin.ModelAdmin):
    """每日统计数据管理"""
    list_display = ['id', 'user', 'stat_date', 'view_count', 'like_count', 'comment_count', 'artwork_count']
    list_filter = ['stat_date']
    search_fields = ['user__username']
    list_per_page = 20
    date_hierarchy = 'stat_date'
